package main

import (
	"encoding/json"
	"fmt"
	"github.com/labstack/gommon/log"
	"io/ioutil"
	"net/http"
)

func api(host string) {
	resp, err := http.Get(fmt.Sprintf("http://%s:6071/version", host))
	if err != nil {
		log.Error(err)
		return
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Error(err)
	}
	var slaveResp map[string][]map[string]interface{}
	err = json.Unmarshal(body, &slaveResp)
	if err != nil {
		log.Error(err)
	}
	slaves := slaveResp["slaves"]

	for _, slave := range slaves {
		fmt.Println(slave["hostname"])
	}
}

func main() {
	api("20.26.33.130")
}
